package com.ym.b2b.upload.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ym.b2b.commons.exception.BaseException;
import com.ym.b2b.commons.service.BaseService;
import com.ym.b2b.upload.dao.EmBUploadDAO;
import com.ym.b2b.upload.service.EmBUploadService;
import com.ym.b2b.upload.sqlbean.EmBUpload;
import com.zc.commons.base.Page;
import com.zc.commons.base.Result;

@Service
public class EmBUploadServiceImpl extends BaseService implements EmBUploadService {

    @Autowired
    private EmBUploadDAO uploadDao;

    @Override
    public Result insertEmBUpload(EmBUpload emBUpload) {
        Result result = new Result();
        try {
            uploadDao.insertEmBUpload(emBUpload);
            result.setResult("上传图片成功!");
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new BaseException(Result.CODE_100, "上传图片【SQL】异常!");
        }
        return result;
    }

    @Override
    public Result searchPageEmBUpload(EmBUpload emBUpload, Page<EmBUpload> page) {
        Result result = new Result();
        try {
            result.setResultPage(uploadDao.searchPageEmBUpload(emBUpload, page));
        } catch (Exception e) {
            throw new BaseException(Result.CODE_100, "查询异常");
        }
        return result;
    }

    @Override
    public int deleteMultipleEmBUpload(String uploadIdList) {
        int rows = uploadDao.deleteMultipleEmBUpload(uploadIdList);
        return rows;
    }

    @Override
    public EmBUpload searchEmBUpload(EmBUpload emBUpload) {
        EmBUpload result = new EmBUpload();
        result = uploadDao.searchEmBUpload(emBUpload.getUploadId());
        return result;
    }

}
